<#-- 表格服务端分页：完美简单实现 http://v4-alpha.getbootstrap.com/components/pagination/-->
<nav aria-label="Page navigation lz-text-center">
    <ul class="pagination justify-content-center lz-align-center">
        <#assign totalPages = ((articleList.total + articleList.size -1) / articleList.size)?floor>
        <#assign totalElements = articleList.total>
        <#assign number = articleList.current>
        <#assign size = articleList.size>

        <#--上一页-->
        <#if articleList.current lte 1>
            <li class="page-item">
                <a class="page-link" href="#">首页</a>
            </li>
        <#else>
            <li class="page-item">
                <a class="page-link" href="/search/${keyword}/1.html">首页</a>
            </li>
        </#if>

        <#--下一页-->
        <#if articleList.current lte 1>
            <li class="page-item disabled">
                <a class="page-link" href="#">上一页</a>
            </li>
        <#else>
            <li class="page-item">
                <a class="page-link" href="/search/${keyword}/${(number-1)?c}.html">上一页</a>
            </li>
        </#if>

        <#--小于等于10页全部显示-->
        <#if totalPages <= 9>
            <#list 1..totalPages as pageIndex>
                <#if number == pageIndex>
                    <li class="page-item active">
                        <a class="page-link" href="javascript:;">${pageIndex?c}</a>
                    </li>
                <#else>
                    <#if pageIndex != 0>
                        <li class="page-item">
                            <a class="page-link" href="/search/${keyword}/${pageIndex?c}.html">${pageIndex?c}</a>
                        </li>
                    </#if>

                </#if>
            </#list>
        </#if>

        <#--大于10页：显示前5页，最后3页，中间用 ...-->
        <#if totalPages gt 9>
        <#-- 2.当前页码小于4[1..9] -->
            <#if number lt 5>
                <#list 1..9 as index>
                    <#if number == index>
                        <li class="page-item active">
                            <a class="page-link" href="/search/${keyword}/${index?c}.html">${index?c}</a>
                        </li>
                    <#else>
                        <li class="page-item">
                            <a class="page-link" href="/search/${keyword}/${index?c}.html">${index?c}</a>
                        </li>
                    </#if>
                </#list>
            <#else>
            <#--当前大于4 && 当前+4小于总页码-->
                <#if number+4 lt totalPages>
                    <#list number-4..number+4 as index>
                        <#if number == index>
                            <li class="page-item active">
                                <a class="page-link" href="/search/${keyword}/${number?c}.html">${number?c}</a>
                            </li>
                        <#else>
                            <li class="page-item">
                                <a class="page-link" href="/search/${keyword}/${index?c}.html">${index?c}</a>
                            </li>
                        </#if>
                    </#list>
                <#else>
                <#--当前大于4 && 当前+4大于总页码-->
                    <#list totalPages-8..totalPages as index>
                        <#if number == index>
                            <li class="page-item active">
                                <a class="page-link" href="/search/${keyword}/${number?c}.html">${number?c}</a>
                            </li>
                        <#else>
                            <li class="page-item">
                                <a class="page-link" href="/search/${keyword}/${index?c}.html">${index?c}</a>
                            </li>
                        </#if>
                    </#list>
                </#if>
            </#if>

        </#if>

        <#--下一页-->
        <#if articleList.current gte totalPages>
            <li class="page-item disabled">
                <a class="page-link" href="#">下一页</a>
            </li>
        <#else>
            <li class="page-item">
                <a class="page-link" href="/search/${keyword}/${(number+1)?c}.html">下一页</a>
            </li>
        </#if>
        <#if totalPages == 0>
            <li class="page-item">
                <a class="page-link" href="/search/${keyword}/1.html">末页</a>
            </li>
        <#else>
            <li class="page-item">
                <a class="page-link" href="/search/${keyword}/${totalPages?c}.html">末页</a>
            </li>
        </#if>

        <!--
           <div class="center" style="padding: 0.1rem 0.15rem;">总共 ${totalPages} 页， ${totalElements} 条记录</div>
        				-->
    </ul>
</nav>

